{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名 王珂 \n",
    "+ 学号 0163446"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "不是贫困户\n",
      "\n",
      "\n",
      "贫困户\n",
      "需要加强义务教育的保障制度\n",
      "需要加强住房安全\n",
      "需要加强食物影响\n",
      "\n",
      "\n",
      "贫困户\n",
      "需要加强义务教育的保障制度\n",
      "需要加强住房安全\n",
      "需要加强饮水安全\n",
      "需要加强食物影响\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "class poor_condition(object):\n",
    "    def __init__(self,x1,x2,x3,x4): \n",
    "        self.education = x1\n",
    "        self.housing_security = x2\n",
    "        self.water_security = x3\n",
    "        self.food = x4\n",
    "    \n",
    "    def poor(self):\n",
    "        count=0\n",
    "        if self.education == False : \n",
    "            count+=1\n",
    "        if self.housing_security == False:\n",
    "            count+=1\n",
    "        if self.water_security == False : \n",
    "            count+=1\n",
    "        if self.food == False:\n",
    "            count+=1\n",
    "        if count>2:\n",
    "            print(\"贫困户\")\n",
    "        else :\n",
    "            print(\"不是贫困户\")\n",
    "            \n",
    "    def helping_measures(self):\n",
    "        count=0\n",
    "        if self.education == False : \n",
    "            count+=1\n",
    "        if self.housing_security == False:\n",
    "            count+=1\n",
    "        if self.water_security == False : \n",
    "            count+=1\n",
    "        if self.food == False:\n",
    "            count+=1\n",
    "        if count>2:\n",
    "            if self.education == False:\n",
    "                print(\"需要加强义务教育的保障制度\")\n",
    "            if self.housing_security == False:\n",
    "                print(\"需要加强住房安全\")\n",
    "            if self.water_security == False : \n",
    "                print(\"需要加强饮水安全\")\n",
    "            if self.food == False:\n",
    "                print(\"需要加强食物影响\")\n",
    "        print('\\n')\n",
    "        \n",
    "Student1=poor_condition(False,True,True,False)\n",
    "Student2=poor_condition(False,False,True,False)\n",
    "Student3=poor_condition(False,False,False,False)\n",
    "Student1.poor()\n",
    "Student1.helping_measures()\n",
    "Student2.poor()\n",
    "Student2.helping_measures()\n",
    "Student3.poor()\n",
    "Student3.helping_measures()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LucyBMI可能偏大\n",
      "\n",
      "\n",
      "Coco体重正常\n",
      "\n",
      "\n",
      "Anna体重正常\n",
      "\n",
      "\n",
      "Lucy体重正常\n",
      "\n",
      "\n",
      "CocoBMI可能偏大\n",
      "\n",
      "\n",
      "Lucy体重正常\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "class student_information(object):\n",
    "    def __init__(self,x1,x2,x3): \n",
    "        self.name = x1\n",
    "        self.grade = x2\n",
    "        self.sleeping_time = x3\n",
    "    \n",
    "    def fat_or_thin(self):\n",
    "        if self.grade>90 and self.sleeping_time<6: \n",
    "            print(\"%sBMI可能偏大\"%self.name)\n",
    "        else :\n",
    "            print(\"%s体重正常\"%self.name)\n",
    "        print(\"\\n\")\n",
    "            \n",
    "    def standardization(self,a1,a2):\n",
    "        if self.grade > a1 and self.sleeping_time<a2:\n",
    "            print(\"%sBMI可能偏大\"%self.name)\n",
    "        else :\n",
    "            print(\"%s体重正常\"%self.name)\n",
    "        print(\"\\n\")\n",
    "            \n",
    "student1=student_information(\"Lucy\",92,5)\n",
    "student2=student_information(\"Coco\",80,7)\n",
    "student3=student_information(\"Anna\",70,4)\n",
    "\n",
    "student1.fat_or_thin()\n",
    "student2.fat_or_thin()\n",
    "student3.fat_or_thin()\n",
    "\n",
    "student1.standardization(92,5)\n",
    "student2.standardization(75,8)\n",
    "student1.standardization(90,4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LucyBMI趋向正常\n",
      "\n",
      "\n",
      "Coco体重正常\n",
      "\n",
      "\n",
      "Anna体重正常\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "class student_information(object):\n",
    "    def __init__(self,x1,x2,x3): \n",
    "        self.name = x1\n",
    "        self.grade = x2\n",
    "        self.sleeping_time = x3\n",
    "    \n",
    "    def fat_or_thin(self,a1,a2):\n",
    "        if self.grade>a1 and self.sleeping_time<a2: \n",
    "            print(\"%sBMI可能偏大\"%self.name)\n",
    "        else :\n",
    "            print(\"%s体重正常\"%self.name)\n",
    "        \n",
    "class running_club(student_information):        \n",
    "    def __init__(self,x1,x2,x3,x4):\n",
    "        super().__init__(x1,x2,x3)\n",
    "        self.run = x4\n",
    "    \n",
    "    def new_standardization(self,a1,a2):\n",
    "        if self.grade > a1 and self.sleeping_time<a2:\n",
    "            if self.run > 30:\n",
    "                print(\"%sBMI趋向正常\"%self.name)\n",
    "            else :\n",
    "                print(\"%sBMI可能偏大\"%self.name)\n",
    "        else:\n",
    "            print(\"%s体重正常\"%self.name)\n",
    "        print(\"\\n\")\n",
    "\n",
    "\n",
    "student_1=running_club(\"Lucy\",92,5,35)\n",
    "student_2=running_club(\"Coco\",80,7,28)\n",
    "student_3=running_club(\"Anna\",70,4,32)\n",
    "\n",
    "student_1.new_standardization(90,6)\n",
    "student_2.new_standardization(75,6)\n",
    "student_3.new_standardization(80,4)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
